<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="app"></div>
    <template id="my-app">
        <h2>歌曲列表</h2>
        <ul>
            <li v-for="(item,index) in list"
                :key="index"
            >
                {{index+1}}---{{item}}
                <a href="#" @click="del(index)">删除</a>
            </li>

        </ul>

    </template>
    <script>
        const App = {
            template: "#my-app",

            data() {
                const list = [
                    '我是歌曲1',
                    '我是歌曲2',
                    '我是歌曲3'
                ]

                return {
                    list
                }
            },
            methods: {
                del(i) {
                    console.log('删除',i)
                    this.list.splice(i, 1)
                }
            }
        }
        Vue.createApp(App).mount('#app')
    </script>
</body>

</html>